InstitutionalArchivesView=Ext.extend(Ext.Panel,{
    constructor:function(a){
        Ext.apply(this,a);
        var all=this.initUIComponents();
        InstitutionalArchivesView.superclass.constructor.call(this,{
            id:'InstitutionalArchivesView',
            title:'制度档案管理',
            region:'center',
            layout:'border',
            border:'false',
            iconCls : "menu-position",
            items : [all.yearGridPanel,all.yearGridSearchPanel,all.yearGridTreePanel]
        })
    },
    initUIComponents:function(){
        var yearGridComponents=new createyeargridview({
            topbar : {
                inputFormName : 'InstitutionalArchivesForm',
                topbarAdd:{
                    hidden:false
                },
                topbarDel:{
                    hidden:false
                }
            },
            search : {
                items : [ {
                    style : "margin:5px 5px 5px 5px;",
                    text : "制度编号"
                }, {
                    columnWidth : 0.2,
                    xtype : "textfield",
                    name : "Q_instilNo_S_LK",
                    maxLength : 256
                } ]
            },
            grid : {
                title : "制度档案列表",
                rowActions:true,
                listUrl : __ctxPath + "/securitysystem/listInstitutionalArchives.do",
                removeUrl : __ctxPath + "/securitysystem/deleteInstitutionalArchives.do",
                fields : [ "id", 'years','institution','instilNo', "instiName", "instiDescribe", "instiVersion","taskEffiveTime"],
                columns : [ {
                    header : "id",
                    dataIndex : "id",
                    hidden : true
                }, {
                    header : "年份",
                    dataIndex : "years",
                    width : 50,
                    hidden:true,
                    sortable : true
                }, {
                    header:"所属机构",
                    dataIndex:'institution',
                    width:100
                },{
                    header : "制度编号",
                    dataIndex : "instilNo",
                    width : 100
                }, {
                    header : "制度名称",
                    dataIndex : "instiName",
                    width : 70
                }, {
                    header : "版本号",
                    dataIndex : "instiVersion",
                    width : 100
                }, {
                    header:"生效时间",
                    dataIndex:"taskEffiveTime",
                    width:100
                }, {
                    header : "制度描述",
                    dataIndex : "instiDescribe",
                    width : 70
                },{
                    header:'修订管理',
                    dataIndex:'instlRevise',
                    width:100,
                    renderer:function(value,metadata,record,rowIndex,colIndex){
                        var revise="";
                        if(true){
                            revise ='<a href="#" id="showRevise" onclick="javaScript:InstitutionalArchivesView.showRevise('+record.data.id+');">修订</a>';  
                        }else{
                            revise = '<a href="#"><font color="#A414A7">已修订</font></a>';
                        }
                        var reviseShow='&nbsp&nbsp&nbsp&nbsp<a href="#" onclick="javaScript:InstitutionalArchivesView.showHistory('+record.data.id+');">历史查看</a>';
                        return revise+reviseShow;
                    }
                }]
            },
            tree : {
                treeUrl : __ctxPath + "/securitysystem/treeLoadInstitutionalArchives.do"
            }
        });
        return yearGridComponents;
    }
});

InstitutionalArchivesView.showRevise=function showRevise(id){
    new InstitutionalArchiXDForm({
        id : id,
        operation : Constant.Operation.EDIT,
        inputFormName : 'InstitutionalArchiXDForm',
        callback:function(a){
            if(a){
                Ext.getCmp("InstitutionalArchivesView").items.items[0].store.reload();
            }
        }
    }).show();
}

InstitutionalArchivesView.showHistory=function showHistory(id){
    SingleGridEject.getView({
        callback:function(records){
            
        },
        multiSel:false,
        inputFormId:"InstituArchRevForm",
        winId:'InstituArchRevViewWin',
        winTitle:'制度历史查看',
        winWidth:700,
        winHeight:480,
        winListurl:__ctxPath + "/securitysystem/listInstituArchRev.do?Q_institutionalId_L_EQ="+id,
        winFields:[{
            name:'id',
            type:"int"
        },'years','institutionalId','institution','instilNo', "instiName", "instiDescribe", "instiVersion","taskEffiveTime","reviseTime","revisePeople","reviseDept"],
        columnModel: [{
            header : "id",
            dataIndex : "id",
            hidden : true
        }, {
            header : "年份",
            dataIndex : "years",
            width : 50,
            hidden:true,
            sortable : true
        },{
            header : "外鍵制度id",
            dataIndex : "institutionalId",
            width : 0,
            hidden:true
        }, {
            header:"所属机构",
            dataIndex:'institution',
            width:100
        },{
            header : "制度编号",
            dataIndex : "instilNo",
            width : 100
        }, {
            header : "制度名称",
            dataIndex : "instiName",
            width : 70
        }, {
            header : "版本号",
            dataIndex : "instiVersion",
            width : 100
        }, {
            header:"生效时间",
            dataIndex:"taskEffiveTime",
            width:100
        }, {
            header : "修订时间",
            dataIndex : "reviseTime",
            width : 70
        }, {
            header : "修订人",
            dataIndex : "revisePeople",
            width : 100
        }, {
            header:"修订部门",
            dataIndex:"reviseDept",
            width:100
        }]
    }).show();
}